import Vue from 'vue'
import store from './store'
import App from './App'
import router from './router'
import 'styles/reset.css'
import 'styles/border.css'
import 'styles/iconfont.css'
import 'styles/animate.css'
import ELEMENT from 'element-ui'
import VueMomentLib from 'vue-moment-lib';
import 'babel-polyfill';


Vue.use(VueMomentLib);

router.beforeEach((to, from, next) => {
  const role = localStorage.getItem('ms_username');
  if (!role && to.path !== '/login') {
    next('/login')
  }
  else {
    next();
  }
});

Vue.config.productionTip = false;
Vue.use((ELEMENT));
Vue.use(require('vue-moment'));
new Vue({
  el: '#app',
  router,
  store,
  components: {App},
  template: '<App/>',
  render: h => h(App)
})
